package com.mhd.usercontroller.exhandler;

import com.baomidou.kaptcha.exception.KaptchaIncorrectException;
import com.mhd.usercontroller.vo.ResultVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExHandler {

    @ExceptionHandler(KaptchaIncorrectException.class)
    public ResultVo handlKaptchaIncorrectEx(KaptchaIncorrectException e){
        return ResultVo.error("验证码错误");
    }

    @ExceptionHandler(Exception.class)
    public ResultVo handlEx(Exception e){
        String message = e.getMessage();
        return ResultVo.error(message);
    }
}
